def solve(nums):
    n = len(nums)
    res = []
    i = 0
    while i < n:
        j = i
        while j < n - 1 and nums[j + 1] == nums[j] + 1:
            j += 1
        if i == j:
            res.append(str(nums[i]))
        else:
            res.append(str(nums[i]) + "->" + str(nums[j]))
        i = j + 1

    return res


if __name__ == "__main__":
    nums = [0, 2, 3, 4, 6, 8, 9]
    print(solve(nums))
